<html>
	<head>

		<script type="text/javascript">

		function extract(html)
		{
			html = html.replace(/<[^>]*>/g,"") // This regex basicaly says find everything that starts with < and ends with >, but does not contain > inside it and replace it with nothing. And things that start with < and end with > are html tags, hence this will delete them all.
			return html;
		};

		function onClick()
		{
			  var html = "<html><head><title>Sample site</title></head><body><div>text<div>more text</div>and more...</div>in body</body></html>";
			  	var output = document.getElementById('output');
		        var p = document.createElement("p");
				var html = document.createTextNode(extract(html));
				p.appendChild(html);
				output.appendChild(p);		     
		};
		</script>
		<title></title>
	</head>
	<body>
		
		<p>
			&lt;html&gt;&lt;head&gt;&lt;title&gt;Sample site&lt;&#47;title&gt;&lt;&#47;head&gt;&lt;body&gt;&lt;div&gt;text&lt;div&gt;more text&lt;&#47;div&gt;and more...&lt;    div&gt;in body&lt;&#47;body&gt;&lt;&#47;html&gt;
		</p>
		<button onclick="onClick()" id="buttonOne">Replace</button>
		<p>
			Output
		</p>
		<div id="output"></div>
	</body>
</html>